Get uiRuntime directly from react-native-worklets#4276
Open
coado wants to merge 12 commits into
Open
Conversation
uiRuntime directly from react-native-worklets
j-piasecki
reviewed
Jul 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR changes how RNGH finds the UI jsi::Runtime for installing UI-thread bindings, preferring the stable react-native-worklets API when available and falling back to the legacy Reanimated _WORKLET_RUNTIME approach.
Changes:
- Add a temporary JS global holder (
__RNGH_UI_WORKLET_RUNTIME_HOLDER) to pass the Worklets UI runtime holder to native during installation. - Update iOS/Android native installation to resolve the UI runtime via Worklets stable API first, then fall back to
_WORKLET_RUNTIME. - Add conditional platform build integration for RNWorklets (CocoaPods + Android Gradle/CMake) gated on Worklets version/API support.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts | Attempts to provide a Worklets UI runtime holder to native during UI bindings install. |
| packages/react-native-gesture-handler/src/global.d.ts | Declares the new temporary global holder type for TypeScript. |
| packages/react-native-gesture-handler/shared/runtime/RNGHRuntimeDecorator.h | Changes UI bindings install signature and adds tryFindUIRuntime. |
| packages/react-native-gesture-handler/shared/runtime/RNGHRuntimeDecorator.cpp | Splits “find UI runtime” from “install bindings” and preserves legacy lookup. |
| packages/react-native-gesture-handler/scripts/gesture_handler_utils.rb | Adds Worklets package/version detection for CocoaPods. |
| packages/react-native-gesture-handler/RNGestureHandler.podspec | Conditionally depends on RNWorklets (>= 0.8.0) when stable API is detected. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerModule.mm | Uses Worklets stable API (when header available) to locate UI runtime before fallback. |
| packages/react-native-gesture-handler/android/src/main/jni/RNGestureHandlerModule.h | Renames native method to reflect installing UI runtime bindings. |
| packages/react-native-gesture-handler/android/src/main/jni/RNGestureHandlerModule.cpp | Uses Worklets stable API under RNGH_USE_WORKLETS, otherwise falls back to legacy lookup. |
| packages/react-native-gesture-handler/android/src/main/jni/CMakeLists.txt | Conditionally links react-native-worklets when enabled. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt | Updates the JNI method name used for installing bindings. |
| packages/react-native-gesture-handler/android/build.gradle | Adds version-gated enablement + dependency wiring for react-native-worklets. |
| apps/basic-example/ios/Podfile.lock | Updates example lockfile to include RNWorklets in pods set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coado
marked this pull request as ready for review
July 14, 2026 15:09
j-piasecki
reviewed
Jul 15, 2026
m-bert
reviewed
Jul 15, 2026
j-piasecki
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
RNGH currently obtains the UI runtime through Reanimated’s private
_WORKLET_RUNTIMEglobal, which stores a rawjsi::Runtimepointer.This PR makes the public
react-native-workletsStable API the preferred way to obtain the UI runtime while preserving the existing Reanimated fallback.Runtime lookup
When compatible Worklets is available:
getUIRuntimeHolder().worklets/Compat/StableApi.h._setGestureStateSyncon the resulting UI runtime.RNGH no longer includes or accesses platform-specific Worklets implementation APIs such as
worklets/android/WorkletsModule.horworklets/apple/WorkletsModule.h.When Worklets is unavailable, too old, or holder retrieval fails, native code falls back to the existing
_WORKLET_RUNTIMEpointer provided by Reanimated.The JavaScript initialization handles the providers independently:
_WORKLET_RUNTIME.Optional dependency integration
react-native-workletsremains optional.Native Worklets integration is enabled only for stable versions
>= 0.8.0:RNWorklets (>= 0.8.0), and definesRNGH_USE_WORKLETS=1.StableApi.his included directly when the macro is enabled, so missing or incorrectly exported headers fail compilation instead of silently selecting the fallback.The shared runtime decorator was also split into:
_WORKLET_RUNTIMEpointer when needed.Test plan
Added Jest coverage and tested on Runtime Decoration example on iOS and Android.